package com.example.bailin.giftsay.guide.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.example.bailin.giftsay.guide.GirlfriendFragment;
import com.example.bailin.giftsay.guide.SelectionFragment;
import com.example.bailin.giftsay.tool.UrlProvide;

import java.util.ArrayList;

/**
 * Created by bailin on 16/8/15.
 *
 * 指南里Fragment复用的适配器
 */
public class GuideAdapter extends FragmentPagerAdapter {
    private String[] strings = {"精选", "送女票", "海淘", "创意生活", "科技苑", "送爸妈",
            "送基友", "送闺蜜", "送同事", "送宝贝", "设计感", "文艺风", "奇葩搞怪", "萌萌哒"};

    private final String[] url = {UrlProvide.SONG_GIRLFRIEND, UrlProvide.HAITAO
            , UrlProvide.ORIGINALITY, UrlProvide.KEJI, UrlProvide.SONG_FSM
            , UrlProvide.SONG_FRIEND, UrlProvide.GIRL_FRIEND, UrlProvide.SONG_COLLEAGUE
            , UrlProvide.SONG_BABY, UrlProvide.DESIGN, UrlProvide.LITERATURE
            , UrlProvide.EXOTIC, UrlProvide.CUTE};

    private Fragment[] fragments;

    public GuideAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        fragments = new Fragment[strings.length];
        if (position == 0) {
            fragments[0] = new SelectionFragment();
        } else {
            fragments[position] = GirlfriendFragment.getInstance(url[position - 1]);
        }
        return fragments[position];
    }

    @Override
    public int getCount() {
        return strings.length;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return strings[position];
    }
}
